<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@page import="java.util.*"%>
<%@page import="java.net.URLEncoder"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>历史图书</title>
</head>
<body>

	<%
		Map<String, Integer> historyBooks = new HashMap<>();
		historyBooks.put("三国", 200);
		historyBooks.put("历史", 100);
		historyBooks.put("水浒传", 50);
	%>

	<h2>历史图书列表</h2>
	<table border="1">
		<thead>
			<tr>
				<td>名称</td>
				<td>价格</td>
				<td>功能</td>
			</tr>

		</thead>

		<tbody>

			<%
				Set<String> keyset = historyBooks.keySet();
				Iterator<String> it = keyset.iterator();
				String key, encodedUrl;
				Integer value;
				while (it.hasNext()) {
					key = it.next();
					value = historyBooks.get(key);
					encodedUrl = URLEncoder.encode(key, "UTF-8"); // 进行url编码
			%>



			<tr>
				<td><%=key%></td>
				<td><%=value%></td>
				<td><a
					href="add_cart.jsp?name=<%=encodedUrl%>&price=<%=value%>&type=history">购买</a></td>

			</tr>


			<%
				}
			%>

		</tbody>
	</table>

	<div>
		<a href="show_cart.jsp">查看购物车</a> <a href="computer_book.jsp">计算机图书列表</a>
	</div>
</body>
</html>